package com.xlb.controller;

import com.xlb.aspect.ApiOperationLog;
import com.xlb.model.vo.category.DeleteCategoryReqVO;
import com.xlb.model.vo.category.FindCategoryPageListReqVO;
import com.xlb.model.vo.category.AddCategoryReqVO;
import com.xlb.service.AdminCategoryService;
import com.xlb.utils.PageResponse;
import com.xlb.utils.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author 小聋包
 * @date 2024/5/16
 * @Version 1.0
 */
@RestController
@RequestMapping("/admin")
@Api(tags = {"Admin 分类模块"})
public class AdminCategoryController {

    @Autowired
    private AdminCategoryService adminCategoryService;

    @PostMapping("/category/add")
    @ApiOperation(value = "添加分类")
    @ApiOperationLog(description = "添加分类")
    public Response addCategory(@RequestBody @Validated AddCategoryReqVO addCategoryReqVO) {
        return adminCategoryService.addCategory(addCategoryReqVO);
    }

    @PostMapping("/category/list")
    @ApiOperation(value = "分类分页数据获取")
    @ApiOperationLog(description = "分类分页数据获取")
    public PageResponse findCategoryPageList(@RequestBody @Validated FindCategoryPageListReqVO findCategoryPageListReqVO) {
        return adminCategoryService.findCategoryPageList(findCategoryPageListReqVO);
    }
    @PostMapping("/category/delete")
    @ApiOperation(value = "删除分类")
    @ApiOperationLog(description = "删除分类")
    public Response deleteCategory(@RequestBody @Validated DeleteCategoryReqVO deleteCategoryReqVO) {
        return adminCategoryService.deleteCategory(deleteCategoryReqVO);
    }

    @PostMapping("/category/select/list")
    @ApiOperation(value = "分类Select 下拉列表数据获取")
    @ApiOperationLog(description = "分类Select 下拉列表数据获取")
    public Response findCategorySelectList(){
        return adminCategoryService.findCategorySelectList();
    }
}
